
export type MenuSectionType = 'link' | 'toggle';

export interface MenuSection {
  id: string;
  name: string;
  type: MenuSectionType;
  path: string;
  icon: string;
  pages?: Array<MenuSection>;
  opened?: boolean;
}

export const menuSections: MenuSection[] = [
  {
    id: 'home',
    name: '首页',
    type: 'link',
    path: '/home',
    icon: 'home'
  },
  {
    id: 'components',
    name: '组件库',
    type: 'toggle',
    icon: 'widgets',
    path: '/components',
    opened: false,
    pages: [
      { id: 'material-ui', name: 'Material 组件', icon: 'extension', path: '/components/material-ui', type: 'link' },
      { id: 'dialogs', name: '弹窗演示', icon: 'chat_bubble_outline', path: '/components/dialogs', type: 'link' },
      { id: 'table-demo', name: '表格组件', icon: 'table_chart', path: '/components/table-demo', type: 'link' }
    ]
  },
  {
    id: 'material-icons',
    name: '图标库',
    type: 'link',
    icon: 'palette',
    path: '/material-icons'
  },
  {
    id: 'forms',
    name: '表单页',
    type: 'toggle',
    icon: 'description',
    path: '/forms',
    opened: false,
    pages: [
      { id: 'basic-form', name: '基础表单', icon: 'assignment', path: '/forms/basic', type: 'link' },
      { id: 'step-form', name: '分步表单', icon: 'view_list', path: '/forms/step', type: 'link' },
      { id: 'advanced-form', name: '高级表单', icon: 'settings', path: '/forms/advanced', type: 'link' }
    ]
  },
  {
    id: 'exception',
    name: '异常页',
    type: 'toggle',
    icon: 'warning',
    path: '/exception',
    opened: false,
    pages: [
      { id: '403', name: '403', icon: 'block', path: '/exception/403', type: 'link' },
      { id: '404', name: '404', icon: 'error_outline', path: '/exception/404', type: 'link' },
      { id: '500', name: '500', icon: 'error', path: '/exception/500', type: 'link' }
    ]
  },
  {
    id: 'i18n-guide',
    name: '国际化指南',
    type: 'link',
    icon: 'language',
    path: '/i18n-guide'
  },
  {
    id: 'rxjs-guide',
    name: 'RxJS 指南',
    type: 'link',
    icon: 'timeline',
    path: '/rxjs-guide'
  },
   {
     id: 'mock-auth',
     name: '模拟认证',
     type: 'link',
     icon: 'security',
     path: '/mock-auth'
   },
   {
     id: 'login',
     name: '登录',
     type: 'link',
     icon: 'login',
     path: '/login'
   }
];

// 全局菜单映射表 - 提供 O(1) 查找性能
export const menuSectionMap = new Map<string, MenuSection>();

// 初始化菜单映射表
menuSections.forEach(section => {
  menuSectionMap.set(section.id, section);
  if (section.pages) {
    section.pages.forEach(page => {
      menuSectionMap.set(page.id, page);
    });
  }
});